package com.tsinjie.metadata.database.comment.support;

import com.tsinjie.metadata.database.comment.TableComment;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by LiuXunming on 2015-10-13.
 * MySQL 数据库
 */
public class MySQLTableComment implements TableComment {

    @Override
    public String getComment(Connection conn, String tableName, String schemaName) throws SQLException {
        String comment = null;
        PreparedStatement pstmt = conn.prepareStatement(DATABASE_MYSQL_QUERY_COMMENT);
        pstmt.setString(1, tableName);
        pstmt.setString(2, schemaName);
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
            comment = rs.getString(1);
        }
        rs.close();
        pstmt.close();
        return comment;
    }
}
